/*
 *	Copyright © 2013 Changsha Shishuo Network Technology Co., Ltd. All rights reserved.
 *	长沙市师说网络科技有限公司 版权所有
 *	http://www.shishuo.com
 */

package com.hlingsoft.kkh.service;

import com.hlingsoft.kkh.dao.CommentsDao;
import com.hlingsoft.kkh.entity.Comments;
import com.hlingsoft.kkh.entity.vo.PageVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 用户服务
 * 
 * @author Zhangjiale
 * 
 */
@Service
public class CommentsService {

	@Autowired
	private CommentsDao CommentsDao;

	/**
	 * 得到用户数据分页
	 * 
	 * @param pageNum
	 * @return pageVo
	 */
	public PageVo<Comments> getCommentsPage(long zhutiId, int pageNum) {
		PageVo<Comments> pageVo = new PageVo<Comments>(pageNum);
		pageVo.setRows(20);
		List<Comments> list = this.getCommentsList(zhutiId,pageVo.getOffset(),
				pageVo.getRows());
		pageVo.setList(list);
		pageVo.setCount(this.getCommentsListCount(zhutiId));
		return pageVo;
	}

	/**
	 * 得到所有用户数据
	 * 
	 * @param offset
	 *            ,rows
	 * @return List<User>
	 */
	public List<Comments> getCommentsList(long zhutiId,long offset, long rows) {
		return CommentsDao.getCommentsList(zhutiId,offset, rows);
	}

	/**
	 * 所有用户数据的数量
	 * 
	 * @return Integer
	 */
	public int getCommentsListCount(long zhutiId) {
		return CommentsDao.getCommentsListCount(zhutiId);
	}
	
	public int addComments(Comments comments){
		return CommentsDao.addComments(comments);
	}
}
